﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
///SessionPage 的摘要说明
/// </summary>
public class SessionPage : System.Web.UI.Page
{
    protected string CurrentUserName = string.Empty;

    protected override void OnPreInit(EventArgs e)
    {
        //clear cache
        Response.Expires = 0;
        Response.Cache.SetNoStore();
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        //current user
        if (Session["CurrentUserName"] != null)
            CurrentUserName = (string)Session["CurrentUserName"];
        else
            Response.Redirect("/", true);

        base.OnPreInit(e);
    }

    public bool VerifyFunction(string FunctionID)
    {
        return VerifyFunction(FunctionID, true);
    }

    public bool VerifyFunction(string FunctionID, bool IsResponseEnd)
    {
        LogicLayer mgr = new LogicLayer();

        bool result = mgr.VerifyFunction("setting", this.CurrentUserName);

        if(!result && IsResponseEnd)
            Response.Redirect("/common/no_auth.aspx");

        return result;
    }
}